################################################################################
### Replication code for:
### "Disguised Repression: Targeting Opponents with Non-Political Crimes 
### to Undermine Dissent"
### Jennifer Pan, Xu Xu, Yiqing Xu
################################################################################

## -----------------------------------------------------------------------------
## -----Setup-------------------------------------------------------------------
## -----------------------------------------------------------------------------

install.packages("haven")
install.packages("interflex")
install.packages("ggplot2")

## Please set working directory to the "Replication" folder
# for example:
# setwd("~/Dropbox/ProjectY/Repression/Replication/")

##############################
## Main Effect (Figures 1)
##############################


##Plotting Figure 2 (a), (b), (c)
d <- read.table("output/plotstd_attrepdis.txt", skip = 3, fill = TRUE)
outcomes <- c("stdsupportdis", "stdsupportrep", "stddissent")
d <- d[,-1]
colnames(d) <- rep(c("coef","se"),3)
d <- rbind(d[1,],c(0,0,0,0,0,0),d[2:3,])
# install.packages("pBrackets")
# library("pBrackets")

#Figure 2(a)
tr.labs <- c("Control", "Political\n(Ref.)", "Tax\nEvasion", "Soliciting\nProstitutes")
s <- d[, c(1:2)]
pdf("graphs/fg_main_stdsupportdis.pdf", width = 5, height = 4.5)
par(mar = c(4, 4, 1, 1))
plot(1, type = "n", xlim = c(0.5, 4.5), ylim = c(-1, 1), axes = FALSE, 
     xlab = "", ylab = ""); box()
mtext("Attitude toward KOL (STDZ, SD=1.24)", 2, line = 2.5)
axis(2); axis(1, at = 1:4, labels = tr.labs, padj = TRUE, cex.axis = 1.1)
abline(h = 0, col = "#AAAAAA70", lwd = 1.5)
for (i in 1:4) {
  par(lend = 3)
  lines(c(i,i), c(s[i,1]-s[i,2]*1.96, s[i,1]+s[i,2]*1.96), lwd = 2, col = 1)
  points(i, s[i,1], pch = 16, cex = 1.5, col = 1)
  text(i,s[i,1]-0.3, labels=s$coef[i])
  text(i,s[i,1]-0.45, labels=paste0("(",s$se[i],")") )
}
graphics.off()

#Figure 2(b)
tr.labs <- c("Political\n(Ref.)", "Tax\nEvasion", "Soliciting\nProstitutes")
s <- d[c(2:4), 2 + c(1:2)]
pdf("graphs/fg_main_stdsupportrep.pdf", width = 5, height = 4.5)
par(mar = c(4, 4, 1, 1))
plot(1, type = "n", xlim = c(0.5, 3.5), ylim = c(-1, 1), axes = FALSE, 
     xlab = "", ylab = ""); box()
mtext("Attitude toward repression (STDZ, SD=2.61)", 2, line = 2.5)
axis(2); axis(1, at = 1:3, labels = tr.labs, padj = TRUE, cex.axis = 1.1)
abline(h = 0, col = "#AAAAAA70", lwd = 1.5)
for (i in 1:3) {
  par(lend = 3)
  lines(c(i,i), c(s[i,1]-s[i,2]*1.96, s[i,1]+s[i,2]*1.96), lwd = 2, col = 1)
  points(i, s[i,1], pch = 16, cex = 1.5, col = 1)
  text(i,s[i,1]-0.35, labels=s$coef[i])
  text(i,s[i,1]-0.5, labels=paste0("(",s$se[i],")") )
}
graphics.off()

#Figure 2(c)
tr.labs <- c("Political\n(Ref.)", "Tax\nEvasion", "Soliciting\nProstitutes")
s <- d[c(2:4), 4 + c(1:2)]
pdf("graphs/fg_main_stddissent.pdf", width = 5, height = 4.5)
par(mar = c(4, 4, 1, 1))
plot(1, type = "n", xlim = c(0.5, 3.5), ylim = c(-1, 1), axes = FALSE, 
     xlab = "", ylab = ""); box()
mtext("Dissent on behalf of KOL (STDZ, SD=0.44)", 2, line = 2.5)
axis(2); axis(1, at = 1:3, labels = tr.labs, padj = TRUE, cex.axis = 1.1)
abline(h = 0, col = "#AAAAAA70", lwd = 1.5)
for (i in 1:3) {
  par(lend = 3)
  lines(c(i,i), c(s[i,1]-s[i,2]*1.96, s[i,1]+s[i,2]*1.96), lwd = 2, col = 1)
  points(i, s[i,1], pch = 16, cex = 1.5, col = 1)
  text(i,s[i,1]-0.3, labels=s$coef[i])
  text(i,s[i,1]-0.45, labels=paste0("(",s$se[i],")") )
}
graphics.off()

##Plotting Figure 3.
s <- read.table("output/plotstd_moral.txt", skip = 3, fill = TRUE)
s <- s[,-1]
colnames(s) <- c("coef","se")
s <- rbind(s[1,],c(0,0),s[2:3,])

tr.labs <- c("Control", "Political\n(Ref.)", "Tax\nEvasion", "Soliciting\nProstitutes")
pdf("graphs/fg_main_stdmorality.pdf", width = 5, height = 4.5)
par(mar = c(4, 4, 1, 1))
plot(1, type = "n", xlim = c(0.5, 4.5), ylim = c(-1.2, 1.2), axes = FALSE, 
     xlab = "", ylab = ""); box()
mtext("KOL's Morality (STDZ, SD=3.2)", 2, line = 2.5)
axis(2); axis(1, at = 1:4, labels = tr.labs, padj = TRUE, cex.axis = 1.1)
abline(h = 0, col = "#AAAAAA70", lwd = 1.5)
for (i in 1:4) {
  par(lend = 3)
  lines(c(i,i), c(s[i,1]-s[i,2]*1.96, s[i,1]+s[i,2]*1.96), lwd = 2, col = 1)
  points(i, s[i,1], pch = 16, cex = 1.5, col = 1)
  text(i,s[i,1]-0.35, labels=s$coef[i])
  text(i,s[i,1]-0.5, labels=paste0("(",s$se[i],")") )
}
graphics.off()


#------------------------------------------------------------------------------
#-----------------------------------Appendix Figures---------------------------
#------------------------------------------------------------------------------

#Figure A1 (a), (b), and (c)
d <- read.table("output/plot_attrepdis.txt", skip = 3, fill = TRUE)
outcomes <- c("supportdis", "supportrep", "dissent")
d <- d[,-1]
colnames(d) <- rep(c("coef","se"),3)
d <- rbind(d[1,],c(0,0,0,0,0,0),d[2:3,])

#Figure A1(a)
tr.labs <- c("Control", "Political\n(Ref.)", "Tax\nEvasion", "Soliciting\nProstitutes")
s <- d[, c(1:2)]
pdf("graphs/fg_main_supportdis.pdf", width = 5, height = 4.5)
par(mar = c(4, 4, 1, 1))
plot(1, type = "n", xlim = c(0.5, 4.5), ylim = c(-1.25, 1.25), axes = FALSE, 
     xlab = "", ylab = ""); box()
mtext("Attitude toward KOL (1-5, avg: 2.8)", 2, line = 2.5)
axis(2); axis(1, at = 1:4, labels = tr.labs, padj = TRUE, cex.axis = 1.1)
abline(h = 0, col = "#AAAAAA70", lwd = 1.5)
for (i in 1:4) {
  par(lend = 3)
  lines(c(i,i), c(s[i,1]-s[i,2]*1.96, s[i,1]+s[i,2]*1.96), lwd = 2, col = 1)
  points(i, s[i,1], pch = 16, cex = 1.5, col = 1)
  text(i,s[i,1]-0.3, labels=s$coef[i])
  text(i,s[i,1]-0.45, labels=paste0("(",s$se[i],")") )
}
graphics.off()


#Figure A1(b)
tr.labs <- c("Political\n(Ref.)", "Tax\nEvasion", "Soliciting\nProstitutes")
s <- d[c(2:4), 2 + c(1:2)]
pdf("graphs/fg_main_supportrep.pdf", width = 5, height = 4.5)
par(mar = c(4, 4, 1, 1))
plot(1, type = "n", xlim = c(0.5, 3.5), ylim = c(-2, 2), axes = FALSE, 
     xlab = "", ylab = ""); box()
mtext("Attitude toward repression (0-10, avg: 7.5)", 2, line = 2.5)
axis(2); axis(1, at = 1:3, labels = tr.labs, padj = TRUE, cex.axis = 1.1)
abline(h = 0, col = "#AAAAAA70", lwd = 1.5)
for (i in 1:3) {
  par(lend = 3)
  lines(c(i,i), c(s[i,1]-s[i,2]*1.96, s[i,1]+s[i,2]*1.96), lwd = 2, col = 1)
  points(i, s[i,1], pch = 16, cex = 1.5, col = 1)
  text(i,s[i,1]-0.6, labels=s$coef[i])
  text(i,s[i,1]-0.85, labels=paste0("(",s$se[i],")") )
}
graphics.off()

#Figure A1(c)
tr.labs <- c("Political\n(Ref.)", "Tax\nEvasion", "Soliciting\nProstitutes")
s <- d[c(2:4), 4 + c(1:2)]
pdf("graphs/fg_main_dissent.pdf", width = 5, height = 4.5)
par(mar = c(4, 4, 1, 1))
plot(1, type = "n", xlim = c(0.5, 3.5), ylim = c(-0.25, 0.25), axes = FALSE, 
     xlab = "", ylab = ""); box()
mtext("Dissent on behalf of KOL (0-1, avg: 0.27)", 2, line = 2.5)
axis(2); axis(1, at = 1:3, labels = tr.labs, padj = TRUE, cex.axis = 1.1)
abline(h = 0, col = "#AAAAAA70", lwd = 1.5)
for (i in 1:3) {
  par(lend = 3)
  lines(c(i,i), c(s[i,1]-s[i,2]*1.96, s[i,1]+s[i,2]*1.96), lwd = 2, col = 1)
  points(i, s[i,1], pch = 16, cex = 1.5, col = 1)
  text(i,s[i,1]-0.1, labels=s$coef[i])
  text(i,s[i,1]-0.13, labels=paste0("(",s$se[i],")") )
}
graphics.off()


#------------------------------Plotting heterogeneous effects (Morality)-------------------
library(haven)
library(interflex)
library(ggplot2)
di <- as.data.frame(read_dta("data/disguise.dta"))
mycol1<-c("white","#999999","cyan3")
mycol2<-c("white","#999999","coral1")
mycol3<-rep("#777777",3)
mycol4<-c("#999999","cyan3","coral1")


##Figure A3: Respondent moral values and attitudes toward kols

ylab <- c("Support for Dissident")
X <- c("moral")
xlab <- c("0, Less Moral --- 100, More Moral")
Z <- c("female", "age", "edulv", "minority", "religious", "married", "work", "work_public", "work_report", "ccp", "income", "eng", "socialmedia", "class")

out1 <- interflex(Y = "supportdis", D = "treattax", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out1, subtitles = c("Control Group", "Political", "Tax Evasion"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE,
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol1)
ggsave(paste0("graphs/fg_me_sup_poltax.pdf"), height = 7, width = 8)

out2 <- interflex(Y = "supportdis", D = "treatpros", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out2, subtitles = c("Control Group", "Political", "Prostitution"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE, 
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol2)
ggsave(paste0("graphs/fg_me_sup_polpros.pdf"), height = 7, width = 8) 


##Figure A4. Three types of moral values and attitudes toward kols

#Figure A4a:Self-Interest
ylab <- c("Support for Dissident")
X <- c("moraleco")
xlab <- c("0, Less Moral --- 100, More Moral")
Z <- c("female", "age", "edulv", "minority", "religious", "married", "work", "work_public", "work_report", "ccp", "income", "eng", "socialmedia", "class")


out1 <- interflex(Y = "supportdis", D = "treattax", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out1, subtitles = c("Control Group", "Political", "Tax Evasion"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE,
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol1)
ggsave(paste0("graphs/fg_me_me_sup_poltax.pdf"), height = 7, width = 8)

out2 <- interflex(Y = "supportdis", D = "treatpros", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out2, subtitles = c("Control Group", "Political", "Prostitution"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE, 
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol2)
ggsave(paste0("graphs/fg_me_me_sup_polpros.pdf"), height = 7, width = 8) 

#Figure A4b: Personal-Sexual
ylab <- c("Support for Dissident")
X <- c("moralsex")
xlab <- c("0, Less Moral --- 100, More Moral")
Z <- c("female", "age", "edulv", "minority", "religious", "married", "work", "work_public", "work_report", "ccp", "income", "eng", "socialmedia", "class")

out1 <- interflex(Y = "supportdis", D = "treattax", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out1, subtitles = c("Control Group", "Political", "Tax Evasion"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE,
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol1)
ggsave(paste0("graphs/fg_me_ms_sup_poltax.pdf"), height = 7, width = 8)

out2 <- interflex(Y = "supportdis", D = "treatpros", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out2, subtitles = c("Control Group", "Political", "Prostitution"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE, 
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol2)
ggsave(paste0("graphs/fg_me_ms_sup_polpros.pdf"), height = 7, width = 8)


#Figure A4c: Violence
ylab <- c("Support for Dissident")
X <- c("moralvio")
xlab <- c("0, Less Moral --- 100, More Moral")
Z <- c("female", "age", "edulv", "minority", "religious", "married", "work", "work_public", "work_report", "ccp", "income", "eng", "socialmedia", "class")
out1 <- interflex(Y = "supportdis", D = "treattax", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out1, subtitles = c("Control Group", "Political", "Tax Evasion"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE,
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol1)
ggsave(paste0("graphs/fg_me_mv_sup_poltax.pdf"), height = 7, width = 8)

out2 <- interflex(Y = "supportdis", D = "treatpros", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out2, subtitles = c("Control Group", "Political", "Prostitution"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE, 
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol2)
ggsave(paste0("graphs/fg_me_mv_sup_polpros.pdf"), height = 7, width = 8) 



#------------------------------Other Heterogeneous Effects-----------------------------

##Figure A5. Respondent income and attitudes toward kols
X <- c("income")
xlab <- c("1, Lowest income --- 100, Highest income")
Z <- c("female", "age", "edulv", "minority", "religious", "married", "work", "work_public", "work_report", "ccp", "income", "eng", "socialmedia", "class")


out1 <- interflex(Y = "supportdis", D = "treattax", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out1, subtitles = c("Control Group", "Political", "Tax Evasion"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE,
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol1)
ggsave(paste0("graphs/fg_me_income_poltax.pdf"), height = 7, width = 8)

out2 <- interflex(Y = "supportdis", D = "treatpros", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out2, subtitles = c("Control Group", "Political", "Prostitution"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE, 
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol2)
ggsave(paste0("graphs/fg_me_income_polpros.pdf"), height = 7, width = 8)

##Figure A6. Respondent education and attitudes toward kols
X <- c("edulv")
xlab <- c("1, Least educated --- 100, Most educated")
Z <- c("female", "age", "edulv", "minority", "religious", "married", "work", "work_public", "work_report", "ccp", "income", "eng", "socialmedia", "class")


out1 <- interflex(Y = "supportdis", D = "treattax", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out1, subtitles = c("Control Group", "Political", "Tax Evasion"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE,
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol1)
ggsave(paste0("graphs/fg_me_edu_poltax.pdf"), height = 7, width = 8)

out2 <- interflex(Y = "supportdis", D = "treatpros", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out2, subtitles = c("Control Group", "Political", "Prostitution"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE, 
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol2)
ggsave(paste0("graphs/fg_me_edu_polpros.pdf"), height = 7, width = 8)


##Figure A7. Liberal values and attitudes toward kols
ylab <- c("Support for Dissident")
X <- c("liberal")
xlab <- c("0, Less Liberal --- 100, More Liberal")
Z <- c("female", "age", "edulv", "minority", "religious", "married", "work", "work_public", "work_report", "ccp", "income", "eng", "socialmedia", "class")


out1 <- interflex(Y = "supportdis", D = "treattax", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out1, subtitles = c("Control Group", "Political", "Tax Evasion"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE,
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol1)
ggsave(paste0("graphs/fg_me_liberal_poltax.pdf"), height = 7, width = 8)

out2 <- interflex(Y = "supportdis", D = "treatpros", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out2, subtitles = c("Control Group", "Political", "Prostitution"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE, 
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol2)
ggsave(paste0("graphs/fg_me_liberal_polpros.pdf"), height = 7, width = 8)

##Figure A8. Trust in government and attitudes toward kols

X <- c("trustcentral")
xlab <- c("1, Lowest trust --- 100, Highest trust")
Z <- c("female", "age", "edulv", "minority", "religious", "married", "work", "work_public", "work_report", "ccp", "income", "eng", "socialmedia", "class")


out1 <- interflex(Y = "supportdis", D = "treattax", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out1, subtitles = c("Control Group", "Political", "Tax Evasion"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE,
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol1)
ggsave(paste0("graphs/fg_me_trgovt_poltax.pdf"), height = 7, width = 8)

out2 <- interflex(Y = "supportdis", D = "treatpros", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out2, subtitles = c("Control Group", "Political", "Prostitution"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE, 
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol2)
ggsave(paste0("graphs/fg_me_trgovt_polpros.pdf"), height = 7, width = 8)


##Figure A9. Political knowledge and attitudes toward kols

X <- c("knowledge")
xlab <- c("1, Least knowledgable --- 100, Most knowledgable")
Z <- c("female", "age", "edulv", "minority", "religious", "married", "work", "work_public", "work_report", "ccp", "income", "eng", "socialmedia", "class")


out1 <- interflex(Y = "supportdis", D = "treattax", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out1, subtitles = c("Control Group", "Political", "Tax Evasion"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE,
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol1)
ggsave(paste0("graphs/fg_me_polkn_poltax.pdf"), height = 7, width = 8)

out2 <- interflex(Y = "supportdis", D = "treatpros", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out2, subtitles = c("Control Group", "Political", "Prostitution"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE, 
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol2)
ggsave(paste0("graphs/fg_me_polkn_polpros.pdf"), height = 7, width = 8)



##Figure A10. Risk tolerance and selfcensorship

X <- c("riskaverse")
xlab <- c("1, Most risk-averse --- 100, Least risk-averse")
Z <- c("female", "age", "edulv", "minority", "religious", "married", "work", "work_public", "work_report", "ccp", "income", "eng", "socialmedia", "class")


out1 <- interflex(Y = "selfcensor", D = "treattax", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out1, subtitles = c("Control Group", "Political", "Tax Evasion"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE,
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol1)
ggsave(paste0("graphs/fg_me_risk_poltax.pdf"), height = 7, width = 8)

out2 <- interflex(Y = "selfcensor", D = "treatpros", X = X, Z = Z, base = "1", cores = 8,
                  estimator = "kernel", data = di, na.rm = TRUE, Xunif = TRUE,  bw = 30)

plot(out2, subtitles = c("Control Group", "Political", "Prostitution"), theme.bw = TRUE,
     ylab = "Marginal Effects of Disguised Repression", xlab = xlab, pool = TRUE, 
     ylim = c(-2,0.8), cex.legend = 1.2, color = mycol2)
ggsave(paste0("graphs/fg_me_risk_polpros.pdf"), height = 7, width = 8)



